/**
 * 
 */
package com.nwpusp.controller.actions;

import java.util.ArrayList;

import com.nwpusp.model.GameModel;
import com.nwpusp.model.session.ConnectionId;

/**
 * @author JustinCao
 *
 */
public abstract class SyncReqAction extends Action {
	
	public static void Response(GameModel model, ConnectionId cid, int syncId) {
		for(SyncReqAction a : syncReqList) {
			if(a.syncId == syncId) {
				if(a.OnSyncResponse(model, cid)) {
					syncReqList.remove(a);
				}
				break;
			}
		}
	}
	
	public static void insertReqAction(SyncReqAction a) {
		syncReqList.add(a);
	}
	
	private static ArrayList<SyncReqAction> syncReqList = new ArrayList<SyncReqAction>();

	private int syncId = -1;
	private ConnectionId monitorCid = null;
	
	public SyncReqAction(ConnectionId monitorCid, int synId) {
		this.syncId = synId;
		this.monitorCid = monitorCid;
	}
	
	public abstract boolean OnSyncResponse(GameModel model, ConnectionId rspCid);
}
